
import 'package:flutter/material.dart';
import 'package:ycbl/page/login/code_login_page.dart';
import 'package:ycbl/page/login/login_way.dart';
import 'package:ycbl/page/main/main_navigator.dart';
import 'package:ycbl/page/splash_page.dart';
import 'package:ycbl/widget/page_route_anim.dart';


/// 页面路由管理 -- 页面名称
class BLRouteName {
  ///启动页
  static const String splash = 'splash';
  ///验证码登录
  static const String login_code = 'login_code';
  /// 登录首页
  static const String loginPage = 'login_page';
  ///主页面
  static const String mainNav = 'main_navigator';


}

class BLRouter {
  // 路由跳转时 调用的方法 RouteSettings 可携带参数
  static Route<dynamic> generateRoute(RouteSettings settings) {
    //根据路由名字 返回对应的页面
    switch(settings.name) {
      case BLRouteName.splash: //启动页
        return CupertinoRouteBuilder(SplashPage());
      case BLRouteName.login_code: //验证码登录
        return CupertinoRouteBuilder(CodeLoginPage(isRootPage: settings.arguments ?? false,));
      case BLRouteName.loginPage: // 登录的首页
        return CupertinoRouteBuilder(LoginWayDemo(isRootPage: settings.arguments ?? false));
      case BLRouteName.mainNav: //主页面
        return CupertinoRouteBuilder(MainNavigator());
      default:
        return CupertinoRouteBuilder(
            Scaffold(
              body: Center(
                child: Text('未定义的页面'),
              ),
            )
        );
    }
  }
}